<?php
/**
 * This is class ErrorController
 *
 */
class ErrorController extends Zend_Controller_Action {
	/**
	 * Handle errors
	 * 
	 * @return void
	 */
	public function errorAction() {
		$errors = $this->_getParam('error_handler', false);
		if (!$errors) {
			// Unknown application error
			$this->getResponse()->setHttpResponseCode(500);
			$this->view->message = 'Unknown application error';
		} else {
			switch ($errors->type) {
				case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
				case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
					// Page not found (404) error
					$this->getResponse()->setHttpResponseCode(404);
					$this->view->message = 'Page not found';
					break;
					
				default:
					// Application (500) error
					$this->getResponse()->setHttpResponseCode(500);
					$this->view->message = 'Application error';
					break;
			}	
		}
		
		$this->view->exception = $errors->exception;
		$this->view->request   = $errors->request;
	}
	
	/**
	 * ACL Access Denied
	 *
	 * @return mixed This is the return value description
	 *
	 */	
	public function denyAction(){
		header('HTTP/1.1 401 Unauthorized');
	}
	
	/**
	 * Generic 404
	 *
	 * @return mixed This is the return value description
	 *
	 */	
	public function noRouteAction(){
		header('HTTP/1.0 404 Not Found'); 
	}	
	
	/**
	 * Generic 500
	 *
	 * @return mixed This is the return value description
	 *
	 */		
	public function crashAction(){
		header('HTTP/1.1 500 Internal Server Error');
		$this->render('error');
	}
	
	/**
	 * This is method notImplementedAction
	 *
	 * @return mixed This is the return value description
	 *
	 */	
	public function notImplementedAction(){
		header('HTTP/1.1 500 Internal Server Error');
	}	
}

?>